const { Service } = require('egg');
const moment = require('moment');
const fse = require('fs-extra');

class FolderService extends Service {

  // 创建目录
  async targetDir() {
    try {
      const time = moment();
      const dirPath = moment(time).format('YYYY/MM/DD');

      fse.ensureDir(`app/public/${dirPath}`);

      return `app/public/${dirPath}`;
    } catch (error) {
      throw error;
    }
  }
}

module.exports = FolderService;
